function onFirstClick()
{
  var curr = document.getElementById("spanPageNum").innerText;
  if (parseInt(curr) > 1)
  {
    document.getElementById("spanPageNum").innerText = "1";
    pagequery();
  }
}

function onPrevClick()
{
  var curr = document.getElementById("spanPageNum").innerText;
  if (parseInt(curr) > 1)
  {
    document.getElementById("spanPageNum").innerText = String(parseInt(curr) - 1);
    pagequery();
  }
}

function onNextClick()
{
  var curr = document.getElementById("spanPageNum").innerText;
  var total = document.getElementById("spanTotalPage").innerText;
  if (parseInt(curr) < parseInt(total))
  {
    document.getElementById("spanPageNum").innerText = String(parseInt(curr) + 1);
    pagequery();
  }
}

function onLastClick()
{
  var curr = document.getElementById("spanPageNum").innerText;
  var total = document.getElementById("spanTotalPage").innerText;
  if (parseInt(curr) < parseInt(total))
  {
    document.getElementById("spanPageNum").innerText = String(total);
    pagequery();
  }
}

function onSpecialClick()
{
  var curr = document.getElementById("spanPageNum").innerText;
  var special = document.getElementById("specialnum").value;
  var total = document.getElementById("spanTotalPage").innerText;
  var isp = parseInt(special);
  if (isp >= 1 && isp <= parseInt(total))
  {
    if(isp != parseInt(curr))
    {
      document.getElementById("spanPageNum").innerText = String(isp);
      pagequery();
    }
  }
  document.getElementById("specialnum").value = "";
}

function onSpecialKeydown()
{
  if (event.keyCode != 13)
  {
    return;
  }
  var curr = document.getElementById("spanPageNum").innerText;
  var special = document.getElementById("specialnum").value;
  var total = document.getElementById("spanTotalPage").innerText;
  var isp = parseInt(special);
  if (isp >= 1 && isp <= parseInt(total))
  {
    if(isp != parseInt(curr))
    {
      document.getElementById("spanPageNum").innerText = String(isp);
      pagequery();
    }
  }
  document.getElementById("specialnum").value = "";
}
